// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import App from './App'
import router from './router'
import ElementUI from 'element-ui';
import 'element-ui/lib/theme-chalk/index.css';
import store from './store'
import {initMenu} from "./utils/menu";
import 'font-awesome/css/font-awesome.css'
import Login from './api/login'
import '../theme/index.css'
import axios from "axios";

Vue.config.productionTip = false
Vue.use(ElementUI,{size: 'small'});
// Vue.prototype.$axios = axios
// 设置请求url前缀
// axios.defaults.baseURL = '/api'
// axios.defaults.headers.post['Content-Type'] = 'application/json'


// 解决后台获取session的值为null情况
axios.defaults.withCredentials = true

// 路由导航守卫
// router.beforeEach((to,from,next)=>{
//   if (window.sessionStorage.getItem('token')) {
//     // 初始化菜单栏
//     initMenu(router, store);
//     // 如果不存在用户信息
//     if (!window.sessionStorage.getItem('userInfo')) {
//       Login.getAdminInfo().then((res) => {
//         console.log("用户信息");
//         console.log(res.data.userFace);
//          if (res) {
//            console.log("存储用户数据中");
//            // 存入用户信息
//            window.sessionStorage.setItem('userInfo',JSON.stringify(res.data));
//            console.log( window.sessionStorage.getItem('userInfo'))
//            next();
//          }
//       })
//     }
//     next();
//   }else {
//     next();
//   }
//
// })

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
